//
//  WalterFlowView.h
//  TipsProject
//
//  Created by Suny on 15/5/15.
//  Copyright (c) 2015年 Suny. All rights reserved.
//

#import <UIKit/UIKit.h>
#import "WaterFlowCell.h"
@class WaterFlowView;

////DataSource and Delegate
@protocol WaterFlowViewDatasource <NSObject>
@required
- (NSInteger)numberOfColumnsInFlowView:(WaterFlowView *)flowView;
- (NSInteger)flowView:(WaterFlowView *)flowView numberOfRowsInColumn:(NSInteger)column;
- (WaterFlowCell *)flowView:(WaterFlowView *)flowView cellForRowAtIndex:(NSInteger)index;
@end
@protocol WaterFlowViewDelegate <NSObject>
@required
- (CGFloat)flowView:(WaterFlowView *)flowView heightForCellAtIndex:(NSInteger)index;
@optional
- (void)flowView:(WaterFlowView *)flowView didSelectAtCell:(WaterFlowCell *)cell ForIndex:(int)index;
- (void)flowView:(WaterFlowView *)flowView willLoadData:(int)page;
@end

////Waterflow View
@interface WaterFlowView : UIScrollView<UIScrollViewDelegate>
{
	NSInteger numberOfColumns ; 
	NSInteger currentPage;
	
	NSMutableArray *_cellHeight; 
	NSMutableArray *_visibleCells; 
	NSMutableDictionary *_reusedCells; 

}

- (void)reloadData;

- (id)dequeueReusableCellWithIdentifier:(NSString *)identifier;

@property (nonatomic, retain) NSMutableArray *cellHeight; //array of cells height arrays, count = numberofcolumns, and elements in each single child array represents is a total height from this cell to the top
@property (nonatomic, retain) NSMutableArray *cellIndex; //array of cells index arrays, count = numberofcolumns
@property (nonatomic, retain) NSMutableArray *visibleCells;  //array of visible cell arrays, count = numberofcolumns
@property (nonatomic, retain) NSMutableDictionary *reusableCells;  //key- identifier, value- array of cells
@property (nonatomic, weak) id <WaterFlowViewDelegate> flowdelegate;
@property (nonatomic, weak) id <WaterFlowViewDatasource> flowdatasource;

@end